﻿using CNKI.TPI.Web.Admin.Model;
using CNKI.TPI.Web.Search.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CNKI.TPI.Web.Admin.IDAO
{
    public interface IUserMgmtDAO
    {
          /// <summary>
        /// 获取所有用户组列表
        /// </summary>
        /// <returns></returns>
       IList<SYS_CMS_GROUP> GetGroup();
          /// <summary>
        /// 获取所有用户IP
        /// </summary>
        /// <returns></returns>
       IList<SYS_CMS_USER_IP> GetGroupIpByUserID(int userid);
       /// <summary>
       /// 保存IP段
       /// </summary>
       /// <returns></returns>
       bool InsertUserIp(SYS_CMS_USER_IP obj);
      
       /// <summary>
       /// 删除用户组
       /// </summary>
       /// <returns></returns>
       bool DeleteUserGroup(string sysid);
       
       /// <summary>
       /// 删除对应的ip段
       /// </summary>
       /// <returns></returns>
       bool DeleteUserIP(string sysidstr);
     
       /// <summary>
       /// 更新IP段
       /// </summary>
       /// <returns></returns>
       bool UpdateUserIp(SYS_CMS_USER_IP obj);
       
         /// <summary>
        /// 获取单位名称
        /// </summary>
        /// <returns></returns>
        IList<SYS_CMS_USER_UNIT> GetUnit();
        
        /// <summary>
        /// 获取部门
        /// </summary>
        /// <returns></returns>
        IList<SYS_CMS_USER_UNIT_DEPT> GetDeptByUnitID(int uid);
          /// <summary>
        /// 获取所有用户列表
        /// </summary>
        /// <returns></returns>
        IList<SYS_CMS_USER> GetUserList();
         /// <summary>
        /// 保存用户信息
        /// </summary>
        /// <returns></returns>
        bool InsertUser(SYS_CMS_USER obj);
        /// <summary>
        /// 更新用户信息
        /// </summary>
        /// <returns></returns>
        bool UpdateUser(SYS_CMS_USER obj);
        /// <summary>
        /// 保存用户组关联表信息
        /// </summary>
        /// <returns></returns>
        bool InsertUserGroup(SYS_CMS_USER_GROUP obj);

         /// <summary>
        /// 根据用户ID删除对应的用户组关联信息
        /// </summary>
        /// <returns></returns>
        bool DelUserGroupByUserID(int uid);
        /// <summary>
        /// 根据用户ID删除对应的用户IP关联信息
        /// </summary>
        /// <returns></returns>
        bool DelUserIPByUserID(int uid);
          /// <summary>
        /// 获取所有数据库列表 分页
        /// </summary>
        /// <returns></returns>
       IList<SYS_CMS_USER> GetUserPageSize(int start, int length, out int count);
          /// <summary>
        /// 获取所有数据库列表 分页
        /// </summary>
        /// <returns></returns>
       IList<SYS_CMS_USER> GetUserByNamePageSize(string username, int start, int length, out int count);
          /// <summary>
        /// 根据用户组名称，查找用户组
        /// </summary>
        /// <param name="groupname"></param>
        /// <param name="start"></param>
        /// <param name="length"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        IList<SYS_CMS_GROUP> GetGroupByNamePageSize(string groupname, int start, int length, out int count);
          /// <summary>
        /// 删除对应的用户
        /// </summary>
        /// <returns></returns>
       bool DeleteUser(string sysidstr);
         /// <summary>
        ///根据用户组 获取所有用户列表 分页
        /// </summary>
        /// <returns></returns>
       IList<SYS_CMS_USER> GetUserByGroupPageSize(int groupID, int start, int length, out int count);
          /// <summary>
        /// 获取所有用户组关系表
        /// </summary>
        /// <returns></returns>
       IList<SYS_CMS_USER_GROUP> GetUserGroup();
         /// <summary>
        /// 保存用户组
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
       bool InsertGroup(SYS_CMS_GROUP obj);
           /// <summary>
        /// 更新用户组
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
       bool UpdateGroup(SYS_CMS_GROUP obj);

       /// <summary>
       /// 修改时判断组名是否存在
       /// </summary>
       /// <param name="name"></param>
       /// <param name="sysid"></param>
       /// <returns></returns>
       bool IsExistUserGroupUpdate(string name, int sysid);
         /// <summary>
        /// 删除密级
        /// </summary>
        /// <param name="sysidstr"></param>
        /// <returns></returns>
       bool DeleteSecurity(string sysidstr);
         /// <summary>
        /// 修改时判断密级名称是否存在
        /// </summary>
        /// <param name="name"></param>
        /// <param name="sysid"></param>
        /// <returns></returns>
       bool IsExistSecurityName(string name, int sysid);
          /// <summary>
        /// 修改时判断密级值是否存在
        /// </summary>
        /// <param name="name"></param>
        /// <param name="sysid"></param>
        /// <returns></returns>
       bool IsExistSecurityValue(string value, int sysid);
          /// <summary>
        /// 保存密级信息
        /// </summary>
        /// <returns></returns>
       bool InsertSecurity(SYS_CMS_SECURITY obj);
       /// <summary>
       /// 更新密级信息
       /// </summary>
       /// <returns></returns>
       bool UpdateSecurity(SYS_CMS_SECURITY obj);

        // <summary>
        /// 获取用户单位 分页
        /// </summary>
        /// <param name="start"></param>
        /// <param name="length"></param>
        /// <param name="count"></param>
        /// <returns></returns>
       IList<SYS_CMS_USER_UNIT> GetUnitPageSize(string unitname,int start, int length, out int count);

       /// <summary>
       /// 保存用户单位信息
       /// </summary>
       /// <returns></returns>
       bool InsertUnit(SYS_CMS_USER_UNIT obj);
 
       /// <summary>
       /// 更新用户单位信息
       /// </summary>
       /// <returns></returns>
       bool UpdateUnit(SYS_CMS_USER_UNIT obj);
        /// 获取下一个用户单位编码
        /// </summary>
        /// <returns></returns>
       string GetNextUnitCode();

           /// <summary>
        /// 删除用户单位
        /// </summary>
        /// <param name="sysidstr"></param>
        /// <returns></returns>
       bool DeleteUnit(string sysidstr);
         /// <summary>
        /// 判断单位名称 是否存在（修改）
        /// </summary>
        /// <param name="name"></param>
        /// <param name="sysid"></param>
        /// <returns></returns>
       bool IsExistUnitUpdate(string name, int sysid);
           /// <summary>
        /// 获取单位下的部门节点
        /// </summary>
        /// <param name="unitid">单位id</param>
        /// <param name="garde">节点级别</param>
        /// <param name="code">父节点code  当code为空时，即获取根节点</param>
        /// <returns></returns>
       IList<SYS_CMS_USER_UNIT_DEPT> GetDept(int unitid, int garde, string code);
        /// <summary>
        /// 删除部门
        /// </summary>
        /// <param name="sysid"></param>
        /// <returns></returns>
       bool DeleteDept(string sysid, string syscode, int unitid);

        /// <summary>
        /// 插入部门信息
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        bool InsertDept(SYS_CMS_USER_UNIT_DEPT obj);
      
        /// <summary>
        /// 更新部门信息
        /// </summary>
        /// <returns></returns>
        bool UpdateDeptName(int id,string deptname);
        /// <summary>
        /// 修改时判断部门名称是否存在
        /// </summary>
        /// <param name="name"></param>
        /// <param name="sysid"></param>
        /// <returns></returns>
        bool IsExistDeptUpdate(string name, int sysid,int unitid);
         /// <summary>
        /// 获取下一个部门编码
        /// </summary>
        /// <param name="unitid"></param>
        /// <param name="parentcode"></param>
        /// <param name="grade"></param>
        /// <returns></returns>
       string GetNextDeptCode(int unitid, string parentcode, int grade);
          /// <summary>
        /// 更新是否有子节点字段
        /// </summary>
        /// <param name="parentcode"></param>
        /// <param name="grade"></param>
        /// <returns></returns>
       bool UpdateDeptChild(string parentcode, int unitid, int flage);

       bool UpdateDBRight(SYS_CMS_USER_ACL_DB_RIGHT dbRight);
       bool InsertDBRight(SYS_CMS_USER_ACL_DB_RIGHT dbRight);
       /// <summary>
       /// 删除权限
       /// </summary>
       /// <param name="uid"></param>
       /// <param name="dbid"></param>
       /// <param name="rightType"></param>
       /// <returns></returns>
       bool DelUserRight(int uid, int dbid, int rightType);
        SYS_CMS_USER GetUserInfoByID(int userid);
           /// <summary>
        /// 根据用户租ID删除对应的用户组IP信息
        /// </summary>
        /// <returns></returns>
       bool DelGroupIPByGroupID(int gid);
    }
}
